Refresh.Web.EditorCommands.addCommand({name:'InsertHtmlMenu',type:'combobox',
		execute:function(ftb,value) { ftb.insertHtml(value); }, 
		getValue:function(ftb) { return null; }, 
		defaultSettings: {title: 'Insert HTML',width: '100px',listWidth:'300px'} });
		
Refresh.Web.EditorCommands.addCommand({name:'FileGallery',type:'button',
		execute:function(ftb,value) { Refresh.Web.PopupWindow.open(Refresh.windowPath + ftb.settings.galleryUrl + '?rootFolder=' + ftb.settings.rootGalleryFolder, 700, 500); }, 
		getValue:function(ftb) { return null; }
});		

Refresh.Web.EditorCommands.addCommand({name:'WordClean',type:'button',getValue:Refresh.Web.QueryMethods.alwaysOn, execute:function(ftb) {
	var t = ftb.getHtml();
	t = Refresh.Web.WordClean.cleanText(t);
	ftb.setHtml(t);
 } });
 
 Refresh.Web.EditorCommands.addCommand({name:'PasteFromWord',execute:function(ftb,value,src) {  
	Refresh.Web.ModalWindow.show(Refresh.windowPath + 'pro-wordpaste.html',530,460,null);	
 },getValue:Refresh.Web.QueryMethods.alwaysOn });
 
 Refresh.Web.WordClean = {	
	cleanText: function(t) {
	t=t.replace(/<FONT[^>]*>/gi,"");
	t=t.replace(/<\/FONT>/gi,"");
	//t=t.replace(/<U>/gi,"");
	//t=t.replace(/<\/U>/gi,"");
	//t=t.replace(/<H[^>]*>/gi,"");
	//t=t.replace(/<\/H[^>]*>/gi,"");
	
	// remove comments
	t=t.replace(/<!--.*?-->/gi,"");
	
	// save BRs
	t=t.replace(/<BR[^>]*>/gi,"&linebreak");
	
	// Change these tags.
	t=t.replace(/<B[^>]*>/gi,"&bold");
	t=t.replace(/<\/B[^>]*>/gi,"&cbold");
	t=t.replace(/<STRONG[^>]*>/gi,"&bold");
	t=t.replace(/<\/STRONG[^>]*>/gi,"&cbold");

	t=t.replace(/<I[^(MG|>)]*>/gi,"&ital");
	t=t.replace(/<\/I[^>]*>/gi,"&cital");
	t=t.replace(/<EM[^>]*>/gi,"&ital");
	t=t.replace(/<\/EM[^>]*>/gi,"&cital");
	
	t=t.replace(/<UL[^>]*>/gi,"&ultag");
	t=t.replace(/<LI[^>]*>/gi,"&litag");
	t=t.replace(/<OL[^>]*>/gi,"&oltag");
	t=t.replace(/<\/OL>/gi,"&olctag");
	t=t.replace(/<\/LI>/gi,"&lictag");
	t=t.replace(/<\/UL>/gi,"&ulctag");

	t=t.replace(/<P[^>]*>/gi,"&parag");
	
	t=t.replace(/&lt;[^>]&gt*;/gi,"");
	t=t.replace(/&lt;\/[^>]&gt*;/gi," ");
	t=t.replace(/<o:[^>]*>/gi,"");
	t=t.replace(/<\/o:[^>]*>/gi,"");
	t=t.replace(/<\?xml:[^>]*>/gi,"");
	t=t.replace(/<\/?st[^>]*>/gi,"");
	t=t.replace(/<[^>]*</gi,"<");
	t=t.replace(/<SPAN[^>]*>/gi,"");
	t=t.replace(/<SPAN[^class]*>/gi,"");
	t=t.replace(/<\/SPAN>/gi,"");
	
	// Clear the inner parts of other tags.
	t=t.replace(/style=[^>]*"/g,' ');
	t=t.replace(/style=[^>]*'/g," ");
	t=t.replace(/style=[^>]*>/g,">");
	t=t.replace(/lang=[^>]*>/g,">");
	t=t.replace(/name=[^>]* /g,"");
	t=t.replace(/name=[^>]*>/g,">");
	t=t.replace(/<A[^>]*>/g,"");
	
	
	// Put the tags back
	t=t.replace(/&linebreak/g,"<br />");
	
	t=t.replace(/&bold/g,"<b>");
	t=t.replace(/&cbold/g,"</b>");

	t=t.replace(/&ital/g,"<i>");
	t=t.replace(/&cital/g,"</i>");

	t=t.replace(/&ultag/g,"<ul>");
	t=t.replace(/&litag/g,"<li>");
	t=t.replace(/&oltag/g,"<ol>");
	t=t.replace(/&olctag/g,"<\/ol>");	
	t=t.replace(/&lictag/g,"<\/li>");
	t=t.replace(/&ulctag/g,"<\/il>");

	t=t.replace(/&parag/g,"<p>");


	return t;	
	}
 };